home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / blit / pixel.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  1.4 KB  |  54 lines

  1. /*                        Copyright (c) 1988 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: pixel.C,v 4.2 88/06/30 11:39:58 sau Exp $
  9.     $Source: /tmp/mgrsrc/src/blit/RCS/pixel.C,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/src/blit/RCS/pixel.C,v $$Revision: 4.2 $";
  12.  
  13. /* set/clear/ or invert a pixel */
  14.  
  15. #include "bitmap.h"
  16. #include "asm.h"
  17.  
  18. bit_point(map,x,y,op)
  19. BITMAP *map;
  20. register int x,y,op;
  21.    {
  22.    register int offset;
  23.     register int *base = BIT_DATA(map);
  24.  
  25.    /* clipping */
  26.  
  27.    if (x<0 || x>BIT_WIDE(map) || y<0 || y>BIT_HIGH(map))
  28.       return(-1);
  29.  
  30.    offset = (y+map->y0)*BIT_LINE(map)+map->x0+x;
  31.   
  32.    switch(OPCODE(op)) {
  33.         case OPCODE(SRC):
  34.         case OPCODE(SRC | DST):
  35.         case OPCODE(SRC | ~DST):
  36.         case OPCODE(~0):
  37.             BF_SET($base,$offset,IMM(1));
  38.          break;
  39.         case OPCODE(~SRC):
  40.         case OPCODE(~(SRC|DST)):
  41.         case OPCODE(DST & ~SRC):
  42.         case OPCODE(0):
  43.             BF_CLR($base,$offset,IMM(1));
  44.          break;
  45.         case OPCODE(SRC ^ DST):
  46.         case OPCODE(~DST):
  47.         case OPCODE(SRC & ~DST):
  48.         case OPCODE(~(SRC&DST)):
  49.             BF_INV($base,$offset,IMM(1));
  50.          break;
  51.       }
  52.    return(0);
  53.    }
  54.